<?
class Spider{
	public static function curl($url)
	{
		$request = Request::factory($url);
		$request->method(Request::GET);
		$request->client()->options(array(
   		CURLOPT_TIMEOUT => 60,
		CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5'
		));
		return  $request->execute()->body();
	}
	public static function gethtml($url)
	{
		$surl = "http://www.youku.com/";
		$cookie_file = dirname(__FILE__)."/temp/youku.txt";
		$ch = curl_init();
		  curl_setopt($ch, CURLOPT_URL, $url);
		  curl_setopt($ch, CURLOPT_REFERER, $surl);
		  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
		  curl_setopt($ch, CURLOPT_HEADER, 1);
		  curl_setopt($ch, CURLOPT_NOBODY, 0);
		  curl_setopt($ch, CURLOPT_TIMEOUT, 60);
		  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); // 允许自动跳转
		  curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
		  //curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
		  $contents = curl_exec($ch);
		  curl_close($ch);
		  return $contents;
	}
	
}
?>